import * as Mock from "mockjs";
const Random = Mock.Random;


//全局设置：设置所有ajax请求的超时时间，模拟网络传输耗时
Mock.setup({
    //延时400s请求到数据
    // timeout: 400
    //延时200-400s请求到数据
    timeout: '200 - 1000'
})

/**一级分类 */
export let goodsFirst = Mock.mock(/\/goodsFirst/, "get", {
    "data|15": [{
        //商品一级分类id
        "goodsFirstCategoryId|+1": 1,
        //商品分类名称
        "goodsFirstCategoryName": "@cword(3)",
        //二级分类的总称
        "goodsSecondTerm": "@cword(4)",
        //一级分类对应二级分类ID  
        "goodsSecondCategoryId|+1": 100
    }]
})

/**二级分类 */
export let goodsSecond = Mock.mock(/\/goodsSecond/, "get", {
    "data|15": [{
        //二级分类ID
        "goodsSecondCategoryId|+1": 100,
        "data|5-15": [{
            //二级分类名称   
            "goodsSecondCategoryName": "@first(3-5)",
            //二级分类图片  
            "goodsSecondCategoryImage": Random.image('55x55', "#67bdc5"),
            //二级分类对应三级分类的ID  
            "goodsThirdCategoryId|+1": 1000
        }]
    }]
})

/**二级分类 */
export let test1 = Mock.mock(/\/mocktest1/, "get", {
    "code": 1,
    "status": 200,
    "data|4": [{
        //二级分类ID
        "id|+1": 100,   // id自增
        "text": "@cname(5,10)",
        "value": "@integer(1,10000)",
    }]
})

/**二级分类 */
export let test2 = Mock.mock(/\/mocktest2/, "get", {
    "code": 1,
    "status": 200,
    "data": {
        //二级分类ID
        "id|+1": 100,   // id自增
        "xdata|20": ["@integer(10,1000)"],
        "ydata1|20": ["@integer(10,1000)"],
        "ydata2|20": ["@integer(10,1000)"],
        "ydata3|20": ["@integer(10,1000)"],
    }
})


/**二级分类 */
export let login = Mock.mock(/\/login/, "get", {
    "code": 1,
    "status": 200,
    "data": {
        //二级分类ID
        'role': 'admin',
        'username': '张三',
        "token": "eyJraWQiOiJWR0pFNlFXTDZjOHZQVjQ0M0NDaUZWQ3JMNWNPaEx2TyIsInR5cCI6IkpXVCIsImFsZyI6IkhTMjU2In0.eyJzdWIiOiI2MTYzNjk0Mzk5MTQzNDMyOTYiLCJjbGllbnRfdHlwZSI6MCwiZXhwIjoxNzAwNTMyNTI4LCJpYXQiOjE3MDA1MTgxMjh9.nGMHnH6C_e6H-ZaES4p3eFq2BzaizMuEZZlmWQ4cBoI"
    }
})

/**二级分类 */
export let roleList = Mock.mock(/\/roleList/, "get", {
    "code": 1,
    "status": 200,
    "data|10": [{
        //二级分类ID
        "id|+1": 100,   // id自增
        "name": '@cname(5,10)',
        "company": '@cword(10,15)',
        "username": '@cname(2,5)',
        "sex": 1,
        "email": '@email',
        "phone": '@integer(13)',
        "createTime": '@date(yyyy-MM-dd hh:mm:ss)',
        "updateTime": '@date(yyyy-MM-dd hh:mm:ss)',
        "status": 1,
    }]
})

/**二级分类 */
export let roleData = Mock.mock(/\/role\/\d{0,}/, "get", {
    "code": 1,
    "status": 200,
    "data": {
        //二级分类ID
        "id|+1": 1,   // id自增
        "name": '@cname(5,10)',
        "company": '@cword(10,15)',
        "username": '@cname(2,5)',
        "sex": 1,
        "email": '@email',
        "phone": '@integer(13)',
        "createTime": '@date(yyyy-MM-dd hh:mm:ss)',
        "updateTime": '@date(yyyy-MM-dd hh:mm:ss)',
        "status": 1,
    }
})